import {OnInit, Component} from "@angular/core";
import {Hero} from "../models/Hero";
import {HeroService} from "../services/hero.service";
import {HeroDetailComponent} from "./hero-detail.component";

@Component({
    selector: 'hero-list',
    templateUrl: 'app/components/hero-list.component.html',
    directives: [HeroDetailComponent],
    providers: [HeroService]
})
export class HeroListComponent implements OnInit {
    heroes: Hero[]
    selectedHero: Hero

    constructor(private service: HeroService) {
    }

    ngOnInit() {
        this.heroes = this.service.getHeroes()
    }

    selectHero(hero: Hero) {
        this.selectedHero = hero
    }
}